const MyPromise = require("./MyPromise")

let promise = new Promise((resolve, reject) => {
    // resolve("成功")
    // reject("失败")
    setTimeout(() => {
        resolve("延迟调用 成功")
        // reject("延迟调用 失败")
    }, 2000)
})

let promise2 = new Promise((resolve, reject) => {
    resolve("新Promise 成功")
    // reject("新Promise 失败")
    // setTimeout(() => {
        // resolve("新Promise 延迟调用 成功")
        // reject("新Promise 延迟调用 失败")
    // }, 2000)
})

promise.then(
    (value) => {
        console.log("first promise fulfilled")
        console.log(value)

        return promise2
    }, 
    (reason) => {
        console.log("first promise rejected")
        console.log(reason)
    }
).then(
    (value) => {
        console.log("second promise fulfilled")
        console.log(value)

        return "second then return value"
    }, 
    (reason) => {
        console.log("second promise rejected")
        console.log(reason)
    }
).then(
    (value) => {
        console.log("third promise fulfilled")
        console.log(value)
    }, 
    (reason) => {
        console.log("third promise rejected")
        console.log(reason)
    }
)